package services

import (
	"dog-blog/app/template/models"
	"strings"
)

var str = `{
	game:[
		"游戏","Unity","Cocos2dx","CocosCreator"
	]
}`

func convertType(tp string) string {
	if tp == "game" {
		return "游戏"
	}

	if tp == "web" {
		return "网站"
	}

	if tp == "other" {
		return "其他"
	}

	return tp
}

func GenArticleListParam(isURL bool, content string) models.HTMLResp {

	if !isURL {
		return models.HTMLResp{CurrPage: "", Category: "", Search: content}
	}

	lastIdx := strings.LastIndex(content, "/")
	categoryEN := content[lastIdx+1 : (len(content))]
	return models.HTMLResp{CurrPage: categoryEN, Category: convertType(categoryEN), Search: ""}
}
